package com.songtech.uitest.cases;

import com.songtech.uitest.components.IBrowserDriverFactory;
import com.songtech.uitest.entities.Indent;
import com.songtech.uitest.module.common.LogInAndOutHandler;
import com.songtech.uitest.resources.IndentResource;
import com.songtech.uitest.resources.ServerResource;
import com.songtech.uitest.util.RollbackHelper;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

/**
 * 开发时做实验的临时测试类，未使用。
 */
@ContextConfiguration(locations = {"classpath:spring-test-config.xml"})
public class TestTemp extends AbstractTestNGSpringContextTests {

    @Autowired
    @Qualifier("browserDriver")
    private IBrowserDriverFactory driverCreater;

    private RemoteWebDriver mainDriver;
    private RemoteWebDriver viceDriver;


    @Autowired
    private RollbackHelper rollbackHelper;

    @Autowired
    private ServerResource serverResource;

    @Autowired
    private IndentResource indentResource;

    @Autowired
    private Indent indent;

    @Autowired
    private LogInAndOutHandler logInAndOutHandler;



    @BeforeClass
    public void init() {
        mainDriver = driverCreater.getMainDriver();

        indent.setTowerId("1218080900403348");
        indent.setMobileId("XD-GD-TT-2018-067256");
        indent.setCurrentBuildType("新址新建站");

        indent.setFlow("07100");
        indent.setStepPosition(0);
    }

    @BeforeMethod
    public void beforeMethod() throws Exception{
        //跑完一个步骤后，还原对应的浏览器到初始状态
        rollbackHelper.rollbackCurrentDriverToInit();
    }

    //走自定义流程
    @Test(enabled=true)
    public void testCustomFlow() throws Exception{
        rollbackHelper.run(indent.getFlow());

    }

    @Test(enabled=true)
    public void testLogout() throws Exception {
        logInAndOutHandler.logout(mainDriver);
        System.out.println("单子当前值：" + indent.getMobileId() +","+ indent.getTowerId() +","+ indent.getCurrentBuildType() +",流程下标位置："+ indent.getStepPosition());
    }

    @AfterClass
    public void tearDown() {
//		driverCreater.closeDriver(driver);
    }
}
